'''
Created on 2010-3-2

@author: Administrator
'''
from jolly.datastructures.AbstractMethod import AbstractMethod
from jolly.datastructures.SearchableContainer import SearchableContainer

class OrderedList(SearchableContainer):
    '''
    Base class from which all ordered list classes are derived.
    '''


    def __init__(self):
        '''
        (OrderedList)->None
        Constructor.
        '''
        super(OrderedList, self).__init__()
     
    def __getitem__(self, i): pass
    __getitem__ = AbstractMethod(__getitem__)
    
    def findPosition(self, obj): pass
    findPosition = AbstractMethod(findPosition)
    
    @staticmethod
    def test(list):
        "OrderedList test program."
        print OrderedList.test.__doc__
        list.insert(1)
        list.insert(2)
        list.insert(3)
        list.insert(4)
        print list
        obj = list.find(2)
        list.withdraw(obj)
        print list
        position = list.findPosition(3)
        position.insertAfter(5)
        print list
        position.insertBefore(6)
        print list
        position.withdraw()
        print list
        for i in list:
            print i